#ifndef UI_ANIM_HELPER_H
#define UI_ANIM_HELPER_H

#include "Lib2D/UIAnimPlayer.h"

namespace UIAnimFlag
{
	enum GlobleUIAnimFlag
	{
		SpriteButtonTouchEnter,
		SpriteButtonTouchExit,
		TextButtonTouchEnter,
		TextButtonTouchExit,
		FlashTextNormal,
		ButtonGroupEnter,
		ButtonGroupExit,
		ButtonGroupEnter_2,
		ButtonGroupExit_2,
		ButtonGroupEnter_3,
		ButtonGroupExit_3,
		ButtonGroupEnter_4,
		ButtonGroupExit_4,
		ButtonGroupEnter_5,
		ButtonGroupExit_5,
		EnterToLeftSide,
		ExitFromLeftSide,
		EnterToRightSide,
		EnterToDownSide,
		EnterToRightUpCorner,
		EnterToLeftUpCorner,
		FlashImageWhenExit,
		TextButtonTouchEnterInMainMenu,
		TextButtonExitInMainMenu,
		RotateAndScalePaper,
		RotateAndScalePaper_Exit,
		RotateAndScaleAndMoveRightPhoto,
		RotateAndScalePhoto,
		RotateAndScaleAndMoveLeftPhoto,
		ScalePhotoAndMoveRight,
		ScalePhoto,
		ScalePhotoAndMoveLeft,
		SuitButtonTouchEnter,
		SuitButtonExit,
		ArtWorksDetailRotate270To180,
		ArtWorksDetailRotate270To0,
		ArtWorksDetailRotate270To90,
		ArtWorksDetailRotate180To270,
		ArtWorksDetailRotate180To90,
		ArtWorksDetailRotate180To0,
	};
}

#define UI_DEFINE_VARIABLE					UITimeline * pTimeline = NULL;UIChannel * pChannel = NULL;UIAnim * pAnim = NULL;

#define UI_CREATE_ANIM(loop, time)			pAnim = UIAnimHelper::CreateUIAnim(loop, time);
#define UI_CREATE_CHANNEL(type, target)		pChannel = UIAnimHelper::CreateUIChannel(type, target);
#define UI_CREATE_TIMELINE(style)			pTimeline = UIAnimHelper::CreateUITimeline(style);

#define UI_ADD_KEY( time, value )			pTimeline->m_keys.push_back(UIAnimKey(time,value));
#define UI_ADD_TIMELINE						pChannel->m_timelines[pTimeline->m_style] = pTimeline;
#define UI_ADD_CHANNEL						pAnim->m_channels.push_back( pChannel );

#define UI_COPY_TIMELINE					pChannel->m_timelines[pTimeline->m_style] = pTimeline;

class UIAnimHelper
{
private:
	UIAnimHelper();

public:
	static void InitHelper();
	static void ClearHelper();

	static UIChannel * GetAvalidChannel();
	static UITimeline * GetAvalidTimeline();
	static UIAnim * GetAvalidAnim();
	static UIAnim *GetGlobleUIAnim(UIAnimFlag::GlobleUIAnimFlag flag);

	static UIAnim *CreateUIAnim(bool loop, float time);
	static UIChannel *CreateUIChannel(UI_ANIMATION::CHANNEL_TYPE type, int targetIndex);
	static UITimeline *CreateUITimeline(UI_ANIMATION::TIMELINE_STYLE style);
};

typedef std::pair<UIAnimFlag::GlobleUIAnimFlag,UIAnim *> TPairUIAnimFlag;

#endif//UI_ANIM_HELPER_H